package com.jxstyle.modular.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSON;
import com.jxstyle.core.base.BaseController;
import com.jxstyle.core.security.SecurityUser;
import com.jxstyle.modular.entity.Menu;
import com.jxstyle.modular.entity.User;
import com.jxstyle.modular.service.UserService;

@Controller
public class IndexController extends BaseController{

	@Autowired
	private UserService userService;
	
	@ResponseBody
	@GetMapping("/usermenu")
	public List<Menu>  menu() {
		User user = super.getUser();
		List<Menu> list = userService.getMenuTreeByUser(user);
		System.out.println("查询菜单列表");
		return list;
	}
	@GetMapping("/")
	public String index() {
		System.out.println("进入首页");
		User user = super.getUser();
		System.out.println(JSON.toJSONString(user, true));
		return "index";
	}

}
